﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using RZWH.WebApi.Model.DBmodels;

namespace RZWH.WebApi.Model;

public partial class FluffypawmediaContext : DbContext
{
    public FluffypawmediaContext()
    {
    }

    public FluffypawmediaContext(DbContextOptions<FluffypawmediaContext> options)
        : base(options)
    {
    }

    public virtual DbSet<Comment> Comments { get; set; }

    public virtual DbSet<Document> Documents { get; set; }

    public virtual DbSet<Process> Processes { get; set; }

    public virtual DbSet<Smartphone> Smartphones { get; set; }

    public virtual DbSet<Smartphonedisplay> Smartphonedisplays { get; set; }

    public virtual DbSet<Smartphoneprocessor> Smartphoneprocessors { get; set; }

    public virtual DbSet<User> Users { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
        => optionsBuilder.UseMySql("server=localhost;port=3306;database=fluffypawmedia;uid=root;pwd=whx1004", ServerVersion.Parse("8.0.21-mysql"));

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<Comment>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("comment", tb => tb.HasComment("手机的评论"));

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.Comment1)
                .HasMaxLength(255)
                .HasComment("评论内容")
                .HasColumnName("comment");
            entity.Property(e => e.Commenttime)
                .HasComment("评论时间")
                .HasColumnType("datetime")
                .HasColumnName("commenttime");
            entity.Property(e => e.PhoneId)
                .HasComment("手机ID")
                .HasColumnName("phoneID");
            entity.Property(e => e.UserId)
                .HasMaxLength(255)
                .HasComment("用户ID")
                .HasColumnName("userID");
        });

        modelBuilder.Entity<Document>(entity =>
        {
            entity
                .HasNoKey()
                .ToTable("document", tb => tb.HasComment("文件上传"));

            entity.Property(e => e.DocumentName).HasMaxLength(100);
        });

        modelBuilder.Entity<Process>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("process", tb => tb.HasComment("处理器表（骁龙/联发科处理器）"));

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.ProcessName)
                .HasMaxLength(255)
                .HasComment("处理器名称")
                .HasColumnName("processName");
        });

        modelBuilder.Entity<Smartphone>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("smartphone");

            entity.Property(e => e.Id)
                .HasComment("手机id")
                .HasColumnName("id");
            entity.Property(e => e.Battery)
                .HasComment("手机电池参数")
                .HasColumnName("battery");
            entity.Property(e => e.Charging)
                .HasComment("充电规格")
                .HasColumnName("charging");
            entity.Property(e => e.DisplayId)
                .HasComment("手机屏幕")
                .HasColumnName("displayId");
            entity.Property(e => e.Game)
                .HasMaxLength(1)
                .HasComment("性能表现（1-低、2-轻度游戏、3-重度游戏）")
                .HasColumnName("game");
            entity.Property(e => e.ImageUrl)
                .HasMaxLength(255)
                .HasComment("图片")
                .HasColumnName("imageURL");
            entity.Property(e => e.Memory)
                .HasMaxLength(255)
                .HasComment("运行内存（8+128，12+256）")
                .HasColumnName("memory");
            entity.Property(e => e.Photo)
                .HasMaxLength(1)
                .HasComment("拍照需求（1-扫码就行 2-要超广角 3-主长广齐全 4-影像旗舰）")
                .HasColumnName("photo");
            entity.Property(e => e.Price)
                .HasComment("二手价格")
                .HasColumnName("price");
            entity.Property(e => e.ProcessorId)
                .HasComment("手机处理器")
                .HasColumnName("processorId");
            entity.Property(e => e.Score)
                .HasComment("打分")
                .HasColumnName("score");
            entity.Property(e => e.SmartPhoneName)
                .HasMaxLength(30)
                .HasComment("手机名称")
                .HasColumnName("smartPhoneName");
            entity.Property(e => e.Summary)
                .HasMaxLength(255)
                .HasComment("手机总结")
                .HasColumnName("summary");
            entity.Property(e => e.System)
                .HasMaxLength(30)
                .HasComment("系统")
                .HasColumnName("system");
            entity.Property(e => e.Time)
                .HasComment("上市时间")
                .HasColumnType("datetime")
                .HasColumnName("time");
            entity.Property(e => e.Weight)
                .HasComment("手机重量")
                .HasColumnName("weight");
            entity.Property(e => e.Wirelesscharging)
                .HasMaxLength(1)
                .HasComment("是否有无线充电（0-没有 1-有）")
                .HasColumnName("wirelesscharging");
        });

        modelBuilder.Entity<Smartphonedisplay>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity.ToTable("smartphonedisplay");

            entity.Property(e => e.Id).HasColumnName("id");
            entity.Property(e => e.DisplaySize)
                .HasMaxLength(30)
                .HasComment("手机屏幕大小")
                .HasColumnName("displaySize");
            entity.Property(e => e.ResolutionRatio)
                .HasMaxLength(30)
                .HasComment("手机屏幕分辨率")
                .HasColumnName("resolutionRatio");
        });

        modelBuilder.Entity<Smartphoneprocessor>(entity =>
        {
            entity.HasKey(e => e.ProcessorId).HasName("PRIMARY");

            entity.ToTable("smartphoneprocessor");

            entity.Property(e => e.ProcessorId)
                .HasComment("处理器ID")
                .HasColumnName("processorId");
            entity.Property(e => e.ProcessorName)
                .HasMaxLength(30)
                .HasComment("处理器名称")
                .HasColumnName("processorName");
        });

        modelBuilder.Entity<User>(entity =>
        {
            entity.HasKey(e => e.UserId).HasName("PRIMARY");

            entity.ToTable("user");

            entity.Property(e => e.UserId)
                .HasComment("用户ID")
                .HasColumnName("userId");
            entity.Property(e => e.RoleId)
                .HasComment("用户类型")
                .HasColumnName("roleId");
            entity.Property(e => e.UserName)
                .HasMaxLength(30)
                .HasComment("用户名称")
                .HasColumnName("userName");
            entity.Property(e => e.UserPassword)
                .HasMaxLength(255)
                .HasComment("用户密码")
                .HasColumnName("userPassword");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
